Technical Q&As
NW 46 - Connecting to a Sleeping or Dozing Macintosh - (31-Jan-97)
Q
We are writing an application that requires us to connect to a remote
machine via TCP/IP and talk to a background application running on that
machine. However, we cannot connect to that machine when it is in
sleep mode. Is there a way to keep the network services alive when a
machine is in sleep mode? I've seen how you can keep the serial port
alive, but not the network services.
A
When a Macintosh (usually a PowerBook) goes into the "sleep" state, it is
incapable of responding to network requests -- the connections
actually shut down. There are some Macintosh computers, however, that
will attempt to go into an energy-efficient mode know as "doze".
The sleep state is easy to prevent and is pretty well documented in the
Power Manager chapter of Inside Mac: Devices under "The Sleep Queue" and
"Sleep Procedures", and there is more information in
TN 1046: Inside
Macintosh: Devices - Power Manager Addenda.
If you wanted to prevent the system from sleeping or dozing, you would:
- Allocate a
SleepQRec
(preferably in the system heap).
- Set it up to call into your
sleepHandler
.
- When the Mac attempts to sleep or doze, it will call your
sleepHandler with a
sleepRequest
or dozeRequest
selector.
- To prevent sleep from occurring, you simply return a nonzero value.
In the doze state, OpenTransport networking is still enabled and TCP
connections that are set up should still function. But it might take
several packets received within a short period (try 10 per second) to wake the
machine from its doze state. You might also consider pinging the machine first
to get it out of doze.
Either way, you should be aware that it will take some time for the networking to
reactivate, especially if virtual memory is enabled and the disk drive must
spin up.
There is more information on controlling the Energy Manager in
TN 1086:
Power Management & The Energy Saver API.
--Vinnie Moscaritolo
Worldwide Developer Technical Support
Technical Q&As
Previous Question |
Contents |
Next Question
To contact us, please use the Contact Us page.